﻿// =================================================================== 
// 项目说明
//====================================================================
// 
// 文件：DataAccessFactory.cs
// 项目名称：

// 创建时间：
// 负责人：
// ===================================================================
using System;
using System.Reflection;
using CommonLib.ComMon;
using CommonLib.IDAL;

namespace CommonLib.DALFactory
{
    /// <summary>
    /// 数据层工厂

    /// </summary>
    public class DataAccessFactory
    {      
        private static readonly string FilePath = ComMon.BSconfig.GetConfig("CommLibPath");
        private static readonly string DALNameSpace = ComMon.BSconfig.GetConfig("DAL");
		//private static readonly string path = System.Configuration.ConfigurationSettings.AppSettings["DAL"];


        public static object CreateObject(string ClassName)
		{
            string CacheKey = DALNameSpace + "." + ClassName;
			object objType = DataCache.GetCache(CacheKey);
			if (objType == null)
			{
				try
				{
					objType = Assembly.Load(FilePath).CreateInstance(CacheKey);					
					DataCache.SetCache(CacheKey, objType);
				}
				catch{}
                
			}
			return objType;
		}
    }
}

